package com.aqie.easy.string;

import java.util.Arrays;

/**
 * 824 山羊拉丁文
 */
public class ToGoatLatin {
    public String toGoatLatin(String S) {
        char[] vowel = {'a','e','i','o','u'};
        // 字符串转数组
        String[] split = S.split("\\s");
        for (int i = 0; i < split.length; i++){
            // 以元音开头
            char c = split[i].charAt(0);
            if (c >= 65 && c <= 90){
                c  += 32;
            }

            if (Arrays.binarySearch(vowel, c) >= 0){
                split[i]  += "ma";

            }else{
                String substring = split[i].substring(1);
                split[i] = substring + split[i].charAt(0) + "ma";
            }
            for (int j = 0; j <= i;j++){
                split[i] += "a";
            }
        }
        return String.join(" ", split) ;
    }

    public static void main(String[] args) {
        char[] vowel = {'a','e','i','o','u','A','E','I','O','U'};
        System.out.println(Arrays.binarySearch(vowel, 'a'));
        System.out.println((int)'a');
        System.out.println((int)'z');
        System.out.println((int)'A');
        System.out.println((int)'Z');
    }

}
